using UnityEngine;
using Photon.Pun;
using System.Collections.Generic;
using UnityEngine.UI;
using Photon.Realtime;
using MyNetwork;
// 在游戏大厅默认房间的玩家名称和所在房间 的 UI 样式
public class PlayerListUI : MonoBehaviourPunCallbacks
{
    // 玩家名称+所在房间 的预制体
    public GameObject playerNameCasePrefab;
    public Transform contentParent;
    public PlayerNameCaseUI playerNameCaseUI;

    public override void OnJoinedRoom()
    {
        if (PhotonNetwork.CurrentRoom.Name == Launcher.defaultRoomName)
        {
            Debug.Log("生成房间中玩家信息");
            GameObject o = PhotonNetwork.Instantiate(playerNameCasePrefab.name, Vector3.zero, Quaternion.identity);
            playerNameCaseUI = o.GetComponent<PlayerNameCaseUI>();
            playerNameCaseUI.PlayerName = PhotonNetwork.NickName;
            playerNameCaseUI.PlayerRoomIndex = -1;
        }
        else
        {
            Debug.Log("测试房间序号：" + ((int)PhotonNetwork.CurrentRoom.Name[4] - 48));
            playerNameCaseUI.PlayerRoomIndex = (int)PhotonNetwork.CurrentRoom.Name[4] - 48;
        }
    }
    public override void OnLeftRoom()
    {
        Debug.Log("离开房间");
    }
}
